package person.zjh.kaoyansharehub.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import person.zjh.kaoyansharehub.dto.PageCommentDTO;
import person.zjh.kaoyansharehub.dto.SaveCommentDTO;
import person.zjh.kaoyansharehub.pojo.Comment;
import person.zjh.kaoyansharehub.result.PageResult;
import person.zjh.kaoyansharehub.result.Result;
import person.zjh.kaoyansharehub.service.CommentService;
import person.zjh.kaoyansharehub.vo.CommentVO;

import java.util.List;

/**
 * @description: TODO
 * @author 郑佳豪
 * @date 2025/2/20 14:12
 * @version 1.0
 */
@RestController
@RequestMapping("/front/comment")
@Slf4j
@RequiredArgsConstructor
public class CommentController {

    private final CommentService commentService;


    @PostMapping("/getComment")
    public Result<PageResult> getComment(@RequestBody PageCommentDTO requestParam){
        log.info("获取评论的参数{}",requestParam);
        return Result.success(commentService.getComment(requestParam));
    }

    @PostMapping("/saveComment")
    public Result saveComment(@RequestBody SaveCommentDTO requestParam){
        log.info("保存评论参数:{}",requestParam);
        return commentService.saveComment(requestParam);
    }

    @GetMapping("/getCommentCount")
    public Result getUserCommentCount(Long userId){
        return commentService.getCommentCountByUserId(userId);
    }

    @DeleteMapping("/deleteComment/{commentId}")
    public Result deleteComment(@PathVariable String commentId){
        log.info("删除的评论id为：{}",commentId);
        commentService.deleteComment(commentId);
        return Result.success();
    }


}
